package m202406.d23;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/6/23 20:41
 */
public class Q704 {
    public int search(int[] nums, int target) {
        int start = 0;
        int end = nums.length;
        while (start < end) {
            int mid = (start + end) / 2;
            if (nums[mid] < target) {
                start = mid + 1;
            } else if (nums[mid] > target) {
                end = mid;
            } else {
                return mid;
            }
        }
        return -1;
    }
}
